﻿namespace SecurityTest
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using Aditi.Security.InputStringFilter;

    using NUnit;
    using NUnit.Framework;

    [TestFixture]
    public class TestStringFilter
    {
        #region Methods

        [Test]
        public void TestContainsPatternAlpha()
        {
            string str = "MyStringContainsAlpha";
            Assert.IsTrue(str.ContainsAlpha());
        }

        [Test]
        public void TestGroup()
        {
            string str = "MyStringContainsALPhaAndGAMMa";
            Assert.IsTrue(str.ContainsGroupAlphaToGamma());
        }

        [Test]
        public void TestRegexGroup()
        {
            string str = "MyStringContains192.150.0.0.0.0.gamma";
            Assert.IsTrue(str.ContainsGroupAlphaToGamma());
        }

        [Test]
        public void TestReplacePatternAlpha()
        {
            string str = "MyaLpHAStringContainsAlpha";
            string expectedstr = "MysomethingStringContainssomething";
            string replacedStr = str.ReplaceAlpha();
            Assert.IsNotNullOrEmpty(replacedStr);
            Assert.AreEqual(expectedstr, replacedStr);
        }

        [Test]
        public void TestReplaceRegexPattern()
        {
            string str = "<html><head><script language=\"javascript\">alert(\"hello\")</script></head></html>";
            string replacedstr = str.ReplaceScript();
            Assert.IsNotNullOrEmpty(replacedstr);
            Assert.AreNotEqual(str, replacedstr);
        }

        [Test]
        public void TestWithCase()
        {
            string str = "MyStringContainsaLpHa";
            Assert.IsTrue(str.ContainsAlphaWithCase());
        }

        #endregion Methods
    }
}